#!/usr/bin/env python
from glob import glob
import sys
import os

dir0 = sys.argv[1]
files = glob(dir0+"/*.raw")
if not os.path.exists(dir0+"_fits"):
    os.system("mkdir "+dir0+"_fits")
for i in range(len(files)):
    print("raw2fits.py "+files[i]+" -y "+sys.argv[2]+" -x -o"+sys.argv[3])
    os.system("raw2fits.py "+files[i]+" -y "+sys.argv[2]+" -x "+sys.argv[3])
    os.system("mv "+files[i][:-3]+"fits "+dir0+"_fits")
